//公共
import myHeader from "/pages/headerfoot/pages/header.vue"
//表格
import uniForms from "/uni_modules/uni-forms/components/uni-forms/uni-forms.vue";
//语言
import Lang from '@/utils/lang.js';
//公共公益方法
import commonBenefit from '@/common/commonbenefit.js';
//公共方法
import Base from '@/common/base.js';
//微信api
import weChat from '@/lib/wechat.js';
//登录api
import Login from '@/lib/login.js';
//用户
import User from '@/lib/user.js';
//公共底部
import Tabbar from "/pages/headerfoot/pages/benefitfooter.vue";
//无数据
import pagesEmpty from "/plugin/pages-empty/components/pages-empty/pages-empty.vue"
//下拉
import uDataSelect from "/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue";



export default {
	components: {
		myHeader,
		uniForms,
		Tabbar,
		pagesEmpty,
	},
	data() {
		return {
			informationfilling: Lang.lang.reviewapplication,
			list: [], //列表
			state: [Lang.lang.unconfirmed, Lang.lang.agree, Lang.lang.disagree],
			lang: Lang.lang, //语言
			ifadd: 0, //是否添加 1=是
			ifstuder: 0, //是否老师 0=否
			downlist: [], //下拉
			school_id: '', //学校
			teacher_team: '', //班级
			downvalue: '', //下拉值
			type:1,//语文
		}
	},
 
	onShow() {
		var that = this;
		that.ifreglogin();
		//获取用户信息
		that.getinfo();
	},
	methods: {
		//判断是否需要注册或者登录与其他
		async ifreglogin() {
			var that = this;
			//注册
			await Base.globalauthorization();
		},
		//获取数据
		getdata(type){
			var that = this;
			that.type=type;
			that.getUserManageList();
			
		},
		//老师下拉
		getteamlist() {
			var that = this;
			var data = {};
			data['school_id'] = that.school_id;
			data['teacher_team'] = that.teacher_team;
			data['my_team'] = 1;
			commonBenefit.getTeamListApiMethod(data).then(res => {
				if (res) {
					that.downlist = res;
				}
			})
		},
		downchange(e) {
			var that = this;
			that.downvalue = e;
			//获取列表
			that.getUserManageList();
		},
		//获取列表
		getUserManageList: function() {
			var that = this;
			var data = {};
			data['teacher_team'] = that.downvalue;
			data['school_id'] = that.school_id;
			console.log(that.type);
			if(that.type==1){
				data['grading_type'] =1;
			}
			if(that.type==2){
				data['grading_type'] = 2;
			}
			commonBenefit.getUserManageListApiMethod(data).then(res => {
				if (res) {
					that.list = res.data;
				}
			})
		},
		//获取用户信息
		getinfo() {
			var that = this;
			var data = {};
			commonBenefit.getUserApiMethod(data).then(res => {
				if (res) {
					var teacher_team = '';
					that.ifadd = res.is_add_user; //是否添加 1=是
					that.ifstuder = res.teacher_team; //是否老师 0=否

					that.school_id = res.school_id; //学校
					teacher_team = that.teacher_team = res.teacher_team; //班级
					if (teacher_team) {
						that.getteamlist(); //老师下拉
						that.ifstuder = 1;
					}
				}
			})
		},
		//查看
		look(e) {
			uni.navigateTo({
				url: commonBenefit.automaticurl('projectuser') + "?userid=" + e
			})
		},
		//跳转
		tzurl() {
			uni.redirectTo({
				url: commonBenefit.automaticurl('reviewapadd')
			})
		},
		//跳转添加班级
		tzurlreviewapadd() {
			uni.redirectTo({
				url: commonBenefit.automaticurl('reviewapgradeadd')
			})
		},
	}
}